// 三方库
{
    // 1
    {
        int a_1 = 45;
        int b_1 = 87;
        if(a_1 * b_1 < 100) {
            UIScrollView *scrp = [[UIScrollView alloc] init];
            NSInteger totalCount = 0;
            if ([scrp isKindOfClass:[UITableView class]]) {
                UITableView *tableView = (UITableView *)scrp;
                for (NSInteger section = 0; section < tableView.numberOfSections; section++) {
                    totalCount += [tableView numberOfRowsInSection:section];
                }
            } else if ([scrp isKindOfClass:[UICollectionView class]]) {
                UICollectionView *collectionView = (UICollectionView *)scrp;
                for (NSInteger section = 0; section < collectionView.numberOfSections; section++) {
                    totalCount += [collectionView numberOfItemsInSection:section];
                }
            }
        }
    }
}


{
    // 2
    {
        if(MAX(1200, 4500) > 5600) {
            CGRect rect = CGRectMake(0, 0, 100, 100);
            CGSize size = CGSizeMake(200, 200);
            NSInteger scaleMode = 1;
            rect = CGRectStandardize(rect);
            size.width = size.width < 0 ? -size.width : size.width;
            size.height = size.height < 0 ? -size.height : size.height;
            CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
            switch (scaleMode) {
                case 0:
                case 2: {
                    if (rect.size.width < 0.01 || rect.size.height < 0.01 ||
                        size.width < 0.01 || size.height < 0.01) {
                        rect.origin = center;
                        rect.size = CGSizeZero;
                    } else {
                        CGFloat scale;
                        if (scaleMode == 0) {
                            if (size.width / size.height < rect.size.width / rect.size.height) {
                                scale = rect.size.height / size.height;
                            } else {
                                scale = rect.size.width / size.width;
                            }
                        } else {
                            if (size.width / size.height < rect.size.width / rect.size.height) {
                                scale = rect.size.width / size.width;
                            } else {
                                scale = rect.size.height / size.height;
                            }
                        }
                        size.width *= scale;
                        size.height *= scale;
                        rect.size = size;
                        rect.origin = CGPointMake(center.x - size.width * 0.5, center.y - size.height * 0.5);
                    }
                } break;
                case 3:
                default: {
                    rect = rect;
                }
            }
        }
    }
}

{
    // 3
    {
        CGFloat c_1 = 400.34;
        if(ceil(c_1) < 120) {
            NSString *name = @"name";
            NSBundle *bundle = [NSBundle mainBundle];
            CGFloat *scale = nil;
            NSString *path;
            if (name.length == 0) {
            }
            if ([name hasSuffix:@"/"]) {
            }
            NSString *extension = name.pathExtension;
            if (extension.length == 0) {
                // If no extension, follow Apple's doc, check PNG format
                extension = @"png";
            }
            name = [name stringByDeletingPathExtension];
            CGFloat providedScale = *scale;
            NSArray *scales = @[@"count",@"NSString",@"stringWithFormat"];
            // Check if file name contains scale
            for (size_t i = 0; i < scales.count; i++) {
                NSNumber *scaleValue = scales[i];
                if ([name hasSuffix:[NSString stringWithFormat:@"@%@x", scaleValue]]) {
                    path = [bundle pathForResource:name ofType:extension];
                    if (path) {
                        *scale = scaleValue.doubleValue; // override
                    }
                }
            }
            // Search with provided scale first
            if (providedScale != 0) {
                NSString *scaledName = [name stringByAppendingFormat:@"@%@x", @(providedScale)];
                path = [bundle pathForResource:scaledName ofType:extension];
                if (path) {
                }
            }
            // Search with preferred scale
            for (size_t i = 0; i < scales.count; i++) {
                NSNumber *scaleValue = scales[i];
                if (scaleValue.doubleValue == providedScale) {
                    // Ignore provided scale
                    continue;
                }
                NSString *scaledName = [name stringByAppendingFormat:@"@%@x", scaleValue];
                path = [bundle pathForResource:scaledName ofType:extension];
                if (path) {
                    *scale = scaleValue.doubleValue; // override
                }
            }
            // Search without scale
            path = [bundle pathForResource:name ofType:extension];
        }
    }
}


{
    // 4
    {
        if(@"NSRegularExpression".length == 0){
            NSString *string = @"NSRegularExpression";
            if (string.length == 0 || [string hasSuffix:@"/"]) {
                NSString *name = string.stringByDeletingPathExtension;
                __block CGFloat scale = 1;
                NSRegularExpression *pattern = [NSRegularExpression regularExpressionWithPattern:@"@[0-9]+\\.?[0-9]*x$" options:NSRegularExpressionAnchorsMatchLines error:nil];
                [pattern enumerateMatchesInString:name options:kNilOptions range:NSMakeRange(0, name.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
                    if (result.range.location >= 3) {
                        scale = [string substringWithRange:NSMakeRange(result.range.location + 1, result.range.length - 2)].doubleValue;
                    }
                }];
            }
        }
    }
}


{
    // 5
    {
        if([@"argumentTypeEncodings" isEqualToString:@"method_getName"]){
            NSArray<NSString *> *_argumentTypeEncodings = nil;
            NSString *_typeEncoding = nil;
            NSString *_name = nil;
            Method * _method = nil;
            SEL _sel = method_getName(*_method);
            const char *name = sel_getName(_sel);
            if (name) {
                _name = [NSString stringWithUTF8String:name];
            }
            const char *typeEncoding = method_getTypeEncoding(*_method);
            if (typeEncoding) {
                _typeEncoding = [NSString stringWithUTF8String:typeEncoding];
            }
            char *returnType = method_copyReturnType(*_method);
            if (returnType) {
                _typeEncoding = [NSString stringWithUTF8String:returnType];
                free(returnType);
            }
            unsigned int argumentCount = method_getNumberOfArguments(*_method);
            if (argumentCount > 0) {
                NSMutableArray *argumentTypes = [NSMutableArray new];
                for (unsigned int i = 0; i < argumentCount; i++) {
                    char *argumentType = method_copyArgumentType(*_method, i);
                    NSString *type = argumentType ? [NSString stringWithUTF8String:argumentType] : nil;
                    [argumentTypes addObject:type ? type : @""];
                    if (argumentType) free(argumentType);
                }
                _argumentTypeEncodings = argumentTypes;
            }
        }
    }
}
